package com.zhilianbao.leyaogo.ui.activity.home;

import android.os.Bundle;
import android.view.KeyEvent;

import com.bql.fragmentation.anim.DefaultHorizontalAnimator;
import com.bql.fragmentation.anim.FragmentAnimator;
import com.zhilianbao.leyaogo.R;
import com.zhilianbao.leyaogo.constants.IntentConfig;
import com.zhilianbao.leyaogo.ui.activity.base.BaseOkHttpActivity;
import com.zhilianbao.leyaogo.ui.fragment.home.SwitchSupplierFragment;
import com.zhilianbao.leyaogo.utils.XToastUtils;

/**
 * ClassName: SelectShopActivity <br>
 * Description: 选择运营商Activity<br>
 * Author: Cyarie <br>
 * Created: 2016/11/1 18:11 <br>
 * Update Time：<br>
 * Update Description：<br>
 */
public class SelectSupplierActivity extends BaseOkHttpActivity {

    private boolean isFirstEnter;

    @Override
    protected int getContentViewLayoutID() {
        return R.layout.fragment_container;
    }

    @Override
    protected void initViewsAndEvents(Bundle savedInstanceState) {
        isFirstEnter = getIntent().getBooleanExtra(IntentConfig.FIRST_SELECT_SUPPLIER, false);
        if (savedInstanceState == null) {
            loadRootFragment(R.id.fl_container, SwitchSupplierFragment.getInstance(isFirstEnter));
        }
    }

    @Override
    protected FragmentAnimator onCreateFragmentAnimator() {
        return new DefaultHorizontalAnimator();
    }

    //    @Override
    //    protected boolean toggleOverridePendingTransition() {
    //        return true;
    //    }
    //
    //    @Override
    //    protected TransitionMode getOverridePendingTransitionMode() {
    //        return TransitionMode.NONE;
    //    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            if (isFirstEnter) {
                //                Bundle bundle = new Bundle();
                //                bundle.putBoolean(IntentConfig.FIRST_SELECT_SUPPLIER, true);
                //                Utils.startActivity(this, MainActivity.class, bundle);
                XToastUtils.showShortToast(getString(R.string.please_select_supplier));
                return true;
            }
            //            if (CheckUtils.isEmpty(Utils.getLocation())) {
            //                ThreadPool.postOnUiDelayed(() -> EventBus.getDefault().post(new EventManager(LeEventCode.MSG_CODE_LOCATION_BACK)), 100);
            //            }
        }
        return super.onKeyDown(keyCode, event);
    }
}
